package javashiyanbaogao;

public class Table {
    private String name;
    private int weight;
    private double width;
    private double length;
    private double height;

    public Table(String name, int weight, double width,
                 double length, double height) {
        this.name = name;
        this.weight = weight;
        this.width = width;
        this.length = length;
        this.height = height;
    }

    public double area() {
        return width * length;
    }

    public void display() {
        System.out.println("名称：" + name);
        System.out.println("重量：" + weight);
        System.out.println("宽度：" + width + " cm");
        System.out.println("长度：" + length + " cm");
        System.out.println("高度：" + height + " cm");
    }

    public void changeweight(int w) {
        this.weight = w;
    }

    public static void main(String[] args) {
        Table myTable = new Table("Dining Table", 40,
                120.0, 80.0, 75.0);
        myTable.display();
        System.out.println("桌面面积：" + myTable.area() + " cm²");
        myTable.changeweight(35);
        System.out.println("修改后的桌子属性：");
        myTable.display();
    }
}
